package kz.kstu.scantest.business.entity;

import javax.persistence.*;
import java.util.Date;

/**
 * @author Filipp_Stankevich
 *         created 01.09.12 20:06
 */
@NamedQueries({
        @NamedQuery(name = CommonEntityConstant.FIND_LAST_KEY, query = "select k from Key k where k.createDate =" +
                " (select max(o.createDate) from Key o)") ,
        @NamedQuery(name = CommonEntityConstant.FIND_KEY_BY_NUMBER, query = "select k from Key k where k.number = :number")
})

@Entity
@Table(name = "KEY")
public class Key implements Identifiable{

    private Long id;
    private String number;
    private Integer writeOffCount;
    private Integer maxCount;
    private Date expiryDate;
    private String digest;
    private Date createDate;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "NUMBER", unique = true)
    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Column(name = "WRITE_OFF_COUNT")
    public Integer getWriteOffCount() {
        return writeOffCount;
    }

    public void setWriteOffCount(Integer writeOffCount) {
        this.writeOffCount = writeOffCount;
    }

    @Column(name = "MAX_COUNT")
    public Integer getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(Integer maxCount) {
        this.maxCount = maxCount;
    }

    @Column(name = "EXPIRY_DATE")
    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    @Column(name = "DIGEST")
    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    @Column(name = "CREATE_DATE")
    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
}
